/*
 * $Id: VisitorGraph.java 25 2011-05-20 14:48:21Z rob.whelan@patientsknowbest.com $ 
 */
package com.representqueens.spark;

/*
 * 
 * Copyright 2006 Larry Ogrodnek
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

import javax.imageio.ImageIO;

import com.representqueens.spark.util.StringConversion;

/**
 * @author Larry Ogrodnek <larry@cheesesteak.net>
 * @version $Revision: 25 $ $Date: 2011-05-20 14:48:21 +0000 (Fri, 20 May 2011) $
 */
public final class VisitorGraph {

    /**
     * @param args
     */
    public static void main(final String[] args) throws IOException {
	final BufferedReader br = new BufferedReader(new FileReader(args[0]));

	final List<DataPoint> data = StringConversion.getData(br.readLine());
	
	final BufferedImage i = BarGraph.createGraph(data,
		BarGraph.DEFAULT_SIZE, BarGraph.DEFAULT_COLOR);

	final File out = new File(args[2]);

	if (out.exists()) {
	    out.delete();
	}

	ImageIO.write(i, "png", out);
    }
}
